package cn.itcast.web.controller;

import cn.itcast.domain.system.User;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class BaseController {

 @Autowired
 protected HttpServletRequest request;

 @Autowired
 protected HttpServletResponse response;

 @Autowired
 protected HttpSession session;

 //获取当前用户公司id
 protected String getLoginCompanyId() {
  Object obj = session.getAttribute("loginUser");
  if (obj != null) {
   User user = (User) obj;
   return user.getCompanyId();
  }
  return "";
 }

 //获取当前用户公司名称
 protected String getLoginCompanyName() {
  Object obj = session.getAttribute("loginUser");
  if (obj != null) {
   User user = (User) obj;
   return user.getCompanyName();
  }
  return "";
 }

 //获取当前登录用户
 protected User getLoginUser() {
  return (User) session.getAttribute("loginUser");
 }
}

